package com.ybbase.framework.config.resource;


import com.ybbase.framework.config.file.FileConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author cg
 * @date 2019-07-30 16:09
 * @DEC
 */
@Configuration
@Slf4j
@EnableWebMvc
public class StaticResourceConfig implements WebMvcConfigurer {
    @Autowired
    private FileConfig fileConfig;
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        //前台打包后的文件
        registry.addResourceHandler("/templates/**")
                .addResourceLocations("classpath:/templates/");
        //activiti modeler静态文件
        registry.addResourceHandler("/activitiModeler/**")
                .addResourceLocations("classpath:/activitiModeler/");
        //swagger静态资源文件
        registry.addResourceHandler("swagger-ui.html")
                .addResourceLocations("classpath:/META-INF/resources/");
        registry.addResourceHandler("/webjars/**")
                .addResourceLocations("classpath:/META-INF/resources/webjars/");
        //将所有C:/Users/gzpost05/Desktop/springboot博客/ 访问都映射到/myTest/** 路径下
        registry.addResourceHandler("/"+fileConfig.fileName+"/**").addResourceLocations("file:"+ fileConfig.filePath+"/");
    }
    /*@Override
    public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
        configurer.enable();
    }*/


}
